package com.terabits.smartriver.meta.dto;

import com.alibaba.fastjson.JSONArray;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.springframework.util.StringUtils;

import java.util.Date;
import java.util.List;

/**
 * Created by Yin on 2019/3/12
 * 点检题 DTO
 */
public class TopicDTO {
    /**
     * 题号
     */
    private Integer id;

    /**
     * 题目类型：1选择  2主观
     */
//    @JsonIgnore
    private Integer type;

    /**
     * 题目描述
     */
    private String topic;

    /**
     * 选项；当type为1时，此字段为null
     */
    @JsonInclude(value = JsonInclude.Include.NON_NULL)
    private List<TopicOptionDTO> options;

    /**
     * 创建人
     */
    @JsonIgnore
    private Integer userId;

    /**
     * 题目创建时间
     */
    @JsonIgnore
    private Date timeCreate;

    /**
     * 备注
     */
    @JsonIgnore
    private String remark;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public List<TopicOptionDTO> getOptions() {
        return options;
    }

    public void setOptions(String optionsStr) {
        List<TopicOptionDTO> options;

        if (StringUtils.isEmpty(optionsStr)) {
            options = null;
        } else {
            options = JSONArray.parseArray(optionsStr, TopicOptionDTO.class);
        }

        this.options = options;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public Date getTimeCreate() {
        return timeCreate;
    }

    public void setTimeCreate(Date timeCreate) {
        this.timeCreate = timeCreate;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }
}
